<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{admin/common/common}">
<head>
    <title>服务列表</title>
</head>

<body layout:fragment="content">
<form id="myForm" th:action="@{/park/list}" th:method="get">
    <div class="page-container">
        <div class="text-c">
            <input type="text" class="input-text" style="width:150px" placeholder="输入园区代码" name="parkCode" th:value="${parkCode}"/>
            <input type="text" class="input-text" style="width:150px" placeholder="输入园区名称" name="parkName" th:value="${parkName}"/>
            <button type="submit" class="btn btn-success">
                <i class="Hui-iconfont">&#xe665;</i>
                搜园区
            </button>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="l">
                <a sa:hasPermission="park:synchronous" href="javascript:;" th:onclick="'javascript:synchronous(\'0\',\'\');'" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe68f;</i>同步边缘服务</a>
            </span>
        </div>
        <table class="table table-border table-bordered table-bg table-hover">
            <thead>
            <tr>
                <th scope="col" colspan="7">园区列表</th>
            </tr>
            <tr class="text-c">
                <th>园区编码</th>
                <th>园区名称</th>
                <th>园区地址</th>
                <th>注册时间</th>
                <th width="35%">描述</th>
            </tr>
            </thead>
            <tbody>
            <tr class="text-c" th:each="model:${pageInfo?.result}" th:object="${model}">
                <td th:text="*{parkCode}">d</td>
                <td th:text="*{parkName}">d</td>
                <td th:text="*{parkAddress}">d</td>
                <td th:text="*{#dates.format(resiterTime, 'yyyy-MM-dd HH:mm')}">2014-6-11 11:11:42</td>
                <td th:text="*{description}">d</td>
            </tr>
            </tbody>
        </table>
        <div th:replace="admin/common/page :: page"></div>
    </div>
</form>

<script type="text/javascript" th:src="@{/js/common/page.js}"></script>
<script th:inline="javascript">
	/**同步到边缘服务**/
	function synchronous(type,id){
	
	    layer.confirm("确认同步边缘服务?",function(index){
	        //此处请求后台程序，下方是成功后的前台处理……
	        $.ajax({
	            type:"get",
	            dataType:"json",
	            url: "/park/synchronous",
	            data:{
	                "timestamp":new Date().getTime(),
	                "synchronousType":type,
	                "parkCode":id
	            },
	            statusCode: {
	                200 : function(data){
	                    if(data.code === "0000"){
		                    succeedMessage("已同步云端!");
		                    setTimeout(function(){
		                      location.reload();
		                    },1000);
	                    }else{
	                       errorMessage(data.message);
	                    }
	
	                },
	                404 : function(data){
	                    errorMessage(data.responseText);
	                },
	                500 : function(){
	                    errorMessage('系统错误!');
	                }
	            }
	        });
	    });
	
	}
</script>
</body>
</html>